import { init, DYNAMIC_CURRENT_ENV } from 'wx-server-sdk';

init({
  env: DYNAMIC_CURRENT_ENV as unknown as string
})

// const db = database()


exports.main = async (event: any, _context) => {
  try {
    if (event.body && typeof event.body === 'string') {
      console.log('type', typeof event.body);
      console.log('body', event.body);
    }
    return {
      code: 0,
    }
  } catch (error) {
    console.warn(error)
    return {
      code: -1,
      errmsg: '出现错误'
    }
  }
}

// async function onChangeAppFuncData(companyId: string, appFuncId: string, dataType: string, data: any) {
//   if (companyId.length === 0) throw new Error("companyId 不能为空");
//   if (appFuncId.length === 0) throw new Error("companyId 不能为空");
//   if (dataType.length === 0) throw new Error("companyId 不能为空");
//   const _ = db.command;
//   return await db.collection('appFuncData').where({
//     companyId,
//     appFuncId,
//     dataType,
//   }).update({
//     data: {
//       data: data,
//       writeCounr: _.inc(1)
//     }
//   })
// }